package com.oi.test01.hw2;

import com.oi.test01.entity.Student;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;

/**
 * @author bin
 * @date 2025 - 03 -25
 **/
public class MainTest01 {
    public static void main(String[] args) throws Exception {
        Student stu = new Student();
        setProperty(stu,"name","徐文斌");
        System.out.println(stu.toString());
    }
    public static void setProperty(Object bean,String proper,String value) throws Exception{
        PropertyDescriptor nameProperty = new PropertyDescriptor(proper,  bean.getClass());
        Method writeMethod = nameProperty.getWriteMethod();
        writeMethod.invoke(bean,value);
    }
}
